<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>视频播放器</title>
    <style>
        body, html {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100vh;
            background: #1a1a1a;
            color: white;
            font-family: Arial, sans-serif;
            overflow: hidden;
        }
        .container {
            display: flex;
            height: 100%;
            box-sizing: border-box;
        }
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: 20px;
            min-width: 400px;
        }
        .sidebar {
            width: 320px;
            background: #2a2a2a;
            display: flex;
            flex-direction: column;
            min-width: 280px;
            position: relative;
        }
        .resizer {
            position: absolute;
            left: -5px;
            top: 0;
            bottom: 0;
            width: 10px;
            cursor: col-resize;
            background: transparent;
            z-index: 100;
        }
        .resizer:hover::after, 
        .resizer.dragging::after {
            content: "";
            position: absolute;
            left: 4px;
            top: 0;
            bottom: 0;
            width: 2px;
            background: #4CAF50;
        }
        .resizer.dragging {
            background: rgba(76, 175, 80, 0.1);
        }
        body.dragging {
            cursor: col-resize !important;
            user-select: none;
        }
        body.dragging * {
            cursor: col-resize !important;
        }
        .sidebar-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            padding: 15px;
            gap: 10px;
        }
        .sidebar-header {
            padding: 10px;
            border-bottom: 1px solid #333;
            display: flex;
            gap: 10px;
            align-items: center;
        }
        .directory-controls {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .path-navigator {
            overflow-x: auto;
            white-space: nowrap;
            padding: 5px 10px;
            background: #222;
            border-radius: 4px;
        }
        .path-part {
            padding: 4px 8px;
            cursor: pointer;
            border-radius: 4px;
            display: inline-block;
        }
        .path-part:hover {
            background: #333;
        }
        .path-separator {
            color: #666;
            margin: 0 5px;
        }
        .directory-list {
            flex: 1;
            overflow-y: auto;
            background: #222;
            border-radius: 4px;
            padding: 10px;
        }
        .view-mode-switch {
            display: flex;
            gap: 5px;
        }
        .control-btn {
            padding: 6px;
            background: #333;
            border: none;
            border-radius: 4px;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
        }
        .control-btn:hover {
            background: #444;
        }
        .control-btn.active {
            background: #4CAF50;
        }
        .control-btn i {
            font-size: 1.2em;
        }
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        .controls {
            display: flex;
            gap: 10px;
            align-items: center;
        }
        .input-group {
            display: flex;
            gap: 10px;
            flex: 1;
            max-width: 600px;
        }
        input[type="text"] {
            flex: 1;
            padding: 8px;
            border: 1px solid #333;
            border-radius: 4px;
            background: #2a2a2a;
            color: white;
        }
        button {
            padding: 8px 15px;
            border: none;
            border-radius: 4px;
            background: #4CAF50;
            color: white;
            cursor: pointer;
            white-space: nowrap;
        }
        button:hover {
            background: #45a049;
        }
        .secondary-btn {
            background: #333;
        }
        .secondary-btn:hover {
            background: #444;
        }
        .video-container {
            flex: 1;
            position: relative;
            background: #000;
            border-radius: 8px;
            overflow: hidden;
            margin-bottom: 20px;
        }
        #videoPlayer {
            width: 100%;
            height: 100%;
            object-fit: contain;
        }
        .file-input {
            display: none;
        }
        select {
            padding: 8px;
            border: 1px solid #333;
            border-radius: 4px;
            background: #2a2a2a;
            color: white;
        }
        .directory-item {
            padding: 8px;
            cursor: pointer;
            border-radius: 4px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .directory-item:hover {
            background: #333;
        }
        .directory-item.selected {
            background: #2d4a2e;
        }
        .directory-item i {
            font-size: 1.2em;
            flex-shrink: 0;
        }
        .directory-item span {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .directory-item .item-time {
            color: #666;
            font-size: 0.85em;
            margin-left: auto;
            flex-shrink: 0;
        }
        .view-controls {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        .grid-view {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
            gap: 10px;
            padding: 5px;
        }
        .grid-view .directory-item {
            flex-direction: column;
            align-items: center;
            text-align: center;
            padding: 10px;
            background: #2a2a2a;
            position: relative;
            height: 140px;
            overflow: hidden;
        }
        .grid-view .directory-item:hover {
            background: #333;
            transform: translateY(-2px);
            transition: all 0.2s ease;
        }
        .grid-view .directory-item .item-icon {
            width: 100px;
            height: 75px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 8px;
            background: #222;
            border-radius: 4px;
            overflow: hidden;
        }
        .grid-view .directory-item .item-icon img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .grid-view .directory-item .item-icon i {
            font-size: 2em;
            color: #666;
        }
        .grid-view .directory-item .item-time {
            position: absolute;
            bottom: 5px;
            left: 0;
            right: 0;
            text-align: center;
            font-size: 0.8em;
            color: #666;
            margin: 0;
            padding: 0 5px;
        }
        .grid-view .directory-item .item-name {
            font-size: 0.9em;
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            word-break: break-all;
            line-height: 1.3;
            height: 2.6em;
            margin-bottom: 15px;
        }
        .file-name {
            padding: 8px;
            font-size: 0.9em;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        /* 自定义滚动条 */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        ::-webkit-scrollbar-track {
            background: #1a1a1a;
        }
        ::-webkit-scrollbar-thumb {
            background: #333;
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: #444;
        }
        .tab-header {
            display: flex;
            padding: 0 10px;
            border-bottom: 1px solid #333;
            background: #222;
        }
        .tab-btn {
            padding: 8px 15px;
            background: transparent;
            border: none;
            color: #888;
            cursor: pointer;
            font-size: 0.9em;
            position: relative;
        }
        .tab-btn:hover {
            color: white;
        }
        .tab-btn.active {
            color: white;
        }
        .tab-btn.active::after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 0;
            right: 0;
            height: 2px;
            background: #4CAF50;
        }
        .tab-content {
            flex: 1;
            overflow: hidden;
            position: relative;
        }
        .tab-panel {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow-y: auto;
            display: none;
        }
        .tab-panel.active {
            display: block;
        }
        .recent-list {
            padding: 10px;
        }
        .recent-header {
            padding: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: #888;
            font-size: 0.9em;
        }
        .recent-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: 10px;
            padding: 10px;
        }
        .recent-item {
            background: #333;
            border-radius: 4px;
            overflow: hidden;
            cursor: pointer;
            transition: transform 0.2s;
        }
        .recent-item:hover {
            transform: scale(1.05);
            background: #444;
        }
        .recent-item.list-mode {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px;
            transform: none;
        }
        .recent-item.list-mode .thumbnail {
            width: 80px;
            height: 45px;
            flex-shrink: 0;
        }
        .recent-item.list-mode .file-info {
            flex: 1;
            overflow: hidden;
        }
        .recent-thumbnail {
            width: 100%;
            aspect-ratio: 16/9;
            background: #222;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .recent-thumbnail img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .recent-thumbnail i {
            font-size: 2em;
            color: #666;
        }
        .file-info {
            padding: 8px;
        }
        .file-meta {
            font-size: 0.8em;
            color: #888;
            margin-top: 4px;
        }
        .folder-icon:before { content: "📁"; }
        .video-icon:before { content: "🎬"; }
        .back-icon:before { content: "⬅"; }
        .list-view-icon:before { content: "📝"; }
        .grid-view-icon:before { content: "📑"; }
    </style>
    <script src="lib/hls.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="main-content">
            <div class="header">
                <div class="input-group">
                    <input type="text" id="videoUrl" placeholder="请输入视频URL">
                    <button id="playButton">播放</button>
                    <button id="localFileBtn" class="secondary-btn">本地文件</button>
                    <input type="file" id="fileInput" class="file-input" accept="video/*,.m3u8">
                    <select id="formatSelector">
                        <option value="mp4">MP4</option>
                        <option value="m3u8">M3U8</option>
                    </select>
                </div>
                <div class="controls">
                    <select id="speedSelector">
                        <option value="0.5">0.5x</option>
                        <option value="1.0" selected>1.0x</option>
                        <option value="1.5">1.5x</option>
                        <option value="2.0">2.0x</option>
                    </select>
                    <button id="fullscreenBtn" class="secondary-btn">全屏</button>
                </div>
            </div>
            <div class="video-container">
                <video id="videoPlayer" controls></video>
            </div>
        </div>
        <div class="sidebar">
            <div class="resizer" id="resizer"></div>
            <div class="sidebar-content">
                <div class="directory-controls">
                    <button id="selectDirBtn" class="secondary-btn">选择目录</button>
                    <div class="view-mode-switch">
                        <button id="listViewBtn" class="control-btn active" title="列表视图">
                            <i class="list-view-icon"></i>
                        </button>
                        <button id="gridViewBtn" class="control-btn" title="网格视图">
                            <i class="grid-view-icon"></i>
                        </button>
                    </div>
                    <input type="file" id="dirInput" webkitdirectory directory multiple style="display: none;">
                </div>
                <div class="path-navigator" id="pathNavigator">
                    <!-- 路径导航将在这里动态生成 -->
                </div>
                <div id="directoryList" class="directory-list">
                    <!-- 目录内容将在这里动态生成 -->
                </div>
            </div>
        </div>
    </div>
    <script src="player.js"></script>
</body>
</html> 